<?php
namespace app\controller;
use think\Request;
use think\View;
use app\model\Alg as AlgModel;
use app\model\Adv as AdvModel;
use app\model\Info as InfoModel;
use app\common\BigWhite;
use app\model\Alg;
class Index
{
    // 上传图片
    public function upload(){

        $file = request()->file('image');
        // 移动到框架应用根目录/uploads/ 目录下
        try{
            // 上传图片到本地服务器
            $saveName = \think\facade\Filesystem::disk('public')->putFile('img',$file);
            $arr = ['code' => 200, 'msg' => '图片上传成功！', 'path' =>  $saveName];
            return json($arr);
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return $this->exceptionHandle($e,'图片上传失败!' . $e->getMessage(),'json','');
        }
    }
    public function getka(request $request){
        $data   =   $request->param();
        if (!$request->has('kaka','get')){
            $data['kaka']='1';
        }
        $kaka = Alg::where('alg',$data['kaka'] )->findOrEmpty();
        if (!$kaka->isEmpty()) {
            return json(['code'=>200,'data'=>$kaka,'msg'=>'成功']);
        }else{
            return json(['code'=>201,'msg'=>'该卡密不存在']);
        }
    }
}
